home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / nwlite / faxdoc.exe / 2852.TXT < prev    next >
Text File  |  1993-05-14  |  4KB  |  100 lines

  1.  
  2.  
  3.                                      FYI
  4.  
  5. (Note:  The origin of this information may be internal or external to Novell. 
  6. Novell makes every effort within its means to verify this information. 
  7. However, the information provided in this document is FOR YOUR INFORMATION
  8. ONLY.  Novell makes no explicit or implied claims to the validity of this
  9. information.)
  10.  
  11.           TITLE:    Testing the DOS Errorlevel
  12.    DOCUMENT ID#:    FYI.P.6071
  13.            DATE:    04DEC92
  14.         PRODUCT:    NetWare Lite
  15. PRODUCT VERSION:    All versions
  16.      SUPERSEDES:    NA
  17.  LITE FAX DOC #:    2852
  18.  
  19. SYMPTOM
  20.  
  21.      NA
  22.  
  23. ISSUE/PROBLEM
  24.  
  25.      Testing the DOS Errorlevel
  26.  
  27.      Programs can set a flag in the DOS environment called errorlevel.  This
  28.      is usually used by the program to pass information to DOS, such as
  29.      returning a pass or fail status of the particular program.  This flag can
  30.      be tested at the DOS level in the following format:
  31.  
  32.           IF not ERRORLEVEL x command
  33.  
  34.      ■    The "not" is optional.
  35.      ■    The "x" is the number to be tested.
  36.      ■    The "command" is the command to be issued if this test passes.
  37.  
  38.      Note:  The purpose of this document is to give general information on how
  39.      to use it with NetWare Lite and not to explain all the functionality of
  40.      the DOS ERRORLEVEL flag.  For further information, please consult your
  41.      DOS documentation.
  42.  
  43.      NetWare Lite v1.1 has the undocumented feature of setting the errorlevel
  44.      flag.  The NET command line utilities will set it according to the status
  45.      of the command.  Errorlevel is set to non-zero if the command fails or
  46.      does not complete properly.
  47.  
  48.           Example:
  49.  
  50.           If the command NET LOGIN TOMMYJO was issued and the user TOMMYJO
  51.           failed to log in for whatever reason (entered an invalid password,
  52.           no servers were found), the DOS errorlevel would be set to non-zero. 
  53.           If TOMMYJO was logged in properly, the errorlevel would be set to
  54.           zero.
  55.  
  56.      The following batch file demonstrates use of this command.  The batch
  57.      file will attempt to log in user MURCHMAN to the network.  If MURCHMAN is
  58.      successfully logged in, the batch file will test to see if the server
  59.      MAHONEY is on the network.  If it is, the LPT1 port will be captured to
  60.      the network printer LASER on server MAHONEY.  Upon failing any of the
  61.      above conditions, error messages will be displayed to the user.  Only
  62.      after everything has been completed will the PROGRAM application be
  63.      executed.
  64.  
  65.           :LOGIN
  66.           NET LOGIN MURCHMAN
  67.           IF ERRORLEVEL 1 GOTO LOGINERR
  68.  
  69.           :CAPTURE
  70.           NET SLIST MAHONEY
  71.           IF ERRORLEVEL 1 GOTO SLISTERR
  72.           NET CAPTURE LPT1 LASER MAHONEY
  73.           ECHO You are logged in to NetWare Lite and port LPT1 has been
  74.           ECHO captured to printer LASER.
  75.           PAUSE
  76.           GOTO DONE
  77.  
  78.           :LOGINERR
  79.           ECHO.
  80.           ECHO You were not correctly logged into the NetWare Lite.  This
  81.           ECHO program will not continue until you are correctly logged in.
  82.          GOTO LOGIN
  83.           
  84.           :SLISTERR
  85.  
  86.           ECHO Server MAHONEY is not currently on the network.
  87.           PAUSE
  88.  
  89.           :DONE
  90.           CLS
  91.           PROGRAM
  92.  
  93.  
  94.      Note: The errorlevel flag is always tested at 1.  Because of the way DOS
  95.      evaluates the errorlevel, all non-zero values will pass on a test of 1.
  96.  
  97. SOLUTION
  98.  
  99.      NA
  100.